home *** CD-ROM | disk | FTP | other *** search
- Path: news.uh.edu!usenet
- From: gregace@aol.com
- Newsgroups: comp.lang.c
- Subject: Checking for Ilegal Input
- Date: Sat, 02 Mar 1996 08:05:59 -0600
- Organization: University of Houston
- Message-ID: <313855C7.5E86@aol.com>
- NNTP-Posting-Host: sip-14124.public-dialups.uh.edu
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
-
- I have a program where you must enter a number between 0 and 15 and check for
- illegal input such as a number not between 0 and 15 or if a character is
- entered.
-
- I used the scanf("%d",&number) to read the input.
-
- I check the illegal input by
-
- while (number<0 or number>15)
- { Printf("Enter a again:");
- scanf("%d",&number);
- }
-
- This check works fine accept when the user enters a character such as the
- letter f. Does anyone know how to check illegal input that is not a number?
-
- Any help appreciated!
-
- Reply before 3-4-96
-
- email:gregace@aol.com
-